<?php
/**
 * Created by PhpStorm.
 * User: kb130
 * Date: 2017/8/21
 * Time: 15:39
 */

namespace util\validate\rules;

/**
 * 给定值的长度必须和参数相同
 * 如果是数字，就值相等，如果是字符串，就长度相等。
 * Class Size
 * @package validate\rules
 */
class Size extends BaseRule
{
    public function verify()
    {
        $this->params += 0;

        if (is_numeric($this->value)) {
            $this->value += 0;

            return $this->value === $this->params;
        }

        return mb_strlen($this->value) === $this->params;
    }
}